﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System.Xml;

namespace Fulcrum.ControlGenerator
{
    /// <summary>
    /// Holds information about a given template part.
    /// </summary>
    class TemplatePartXmlConfiguration : Fulcrum.ControlGenerator.ITemplatePartConfiguration
    {
        public TemplatePartXmlConfiguration(XmlReader xmlReader)
        {
            // TODO Name should never be null or empty
            // TODO Type should never be null or empty
            // TODO Description perhaps could be null or empty, but standardize on one
            this.Name = xmlReader.GetAttribute("name");
            this.Type = xmlReader.GetAttribute("type");
            this.Description = xmlReader.GetAttribute("description");
            this.Optional = XmlReaderHelp.GetOptionalBoolAttributeValue(xmlReader, "optional", false);

            xmlReader.Read();
        }

        public string Name
        {
            get;
            private set;
        }

        public string Type
        {
            get;
            private set;
        }

        public string Description
        {
            get;
            private set;
        }

        public bool Optional
        {
            get;
            private set;
        }
    }
}
